var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BundleManager = require("BundleManager");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_MoreGame = /* */function (_cc$Component51) {
  babel_inherits(l, _cc$Component51);
  var _super55 = babel_createSuper(l);
  function l() {
    var _this119;
    babel_classCallCheck(this, l);
    _this119 = _super55.apply(this, arguments);
    _this119.content = null;
    _this119.myScrollView = null;
    _this119.dircetionTop = true;
    _this119.itemHeight = 115;
    _this119.showOrderReward = 0;
    return _this119;
  }
  babel_createClass(l, [{
    key: "onLoad",
    value: function onLoad() {
      this.content = cc.find("ScrollView/view/content", this.node);
      this.myScrollView = cc.find("ScrollView", this.node).getComponent(cc.ScrollView);
      this.myScrollView.node.on("scroll-began", this.onScrollBegan, this);
      this.myScrollView.node.on("scroll-ended", this.onScrollEnded, this);
      this.init();
    }
  }, {
    key: "init",
    value: function init() {
      for (var _e60 = 0; _e60 < 36; _e60++) {
        cc.instantiate($2BundleManager.default.instance.getBundleRes("Prefab", "BowlingUI/item", cc.Prefab)).parent = this.content;
      }
      this.showOrderReward = this.content.childrenCount;
      this.schedule(this.scrollViewUpdate, .02);
    }
  }, {
    key: "onScrollBegan",
    value: function onScrollBegan() {
      this.unschedule(this.scrollViewUpdate);
    }
  }, {
    key: "onScrollEnded",
    value: function onScrollEnded() {
      if (this.myScrollView.getScrollOffset().y + 1 >= this.myScrollView.getMaxScrollOffset().y) {
        this.unschedule(this.scrollViewUpdate);
        this.myScrollView.scrollToBottom(0);
        this.myScrollView.scrollToTop(this.showOrderReward * this.itemHeight * .01);
        this.dircetionTop = true;
      } else if (this.myScrollView.getScrollOffset().y - 1 <= 0) {
        this.unschedule(this.scrollViewUpdate);
        this.myScrollView.scrollToTop(0);
        this.myScrollView.scrollToBottom(this.showOrderReward * this.itemHeight * .01);
        this.dircetionTop = false;
      } else if (this.dircetionTop) {
        var _e61 = Math.ceil(this.myScrollView.getScrollOffset().y / this.itemHeight);
        this.myScrollView.scrollToTop(_e61 * this.itemHeight * .01);
      } else {
        var _e62 = Math.ceil((this.myScrollView.getMaxScrollOffset().y - this.myScrollView.getScrollOffset().y) / this.itemHeight);
        this.myScrollView.scrollToBottom(_e62 * this.itemHeight * .01);
      }
      this.schedule(this.scrollViewUpdate, .02);
    }
  }, {
    key: "scrollViewUpdate",
    value: function scrollViewUpdate() {
      if (this.myScrollView.getScrollOffset().y + 1 >= this.myScrollView.getMaxScrollOffset().y) {
        this.unschedule(this.scrollViewUpdate);
        this.myScrollView.scrollToBottom(0);
        this.myScrollView.scrollToTop(this.showOrderReward * this.itemHeight * .01);
        this.dircetionTop = true;
      } else if (this.myScrollView.getScrollOffset().y - 1 <= 0) {
        this.unschedule(this.scrollViewUpdate), this.myScrollView.scrollToTop(0), this.myScrollView.scrollToBottom(this.showOrderReward * this.itemHeight * .01), this.dircetionTop = false;
      }
    }
  }]);
  return l;
}(cc.Component);
def_MoreGame = cc__decorate([ccp_ccclass], def_MoreGame);
exports.default = def_MoreGame;